package terminal_enum

import "gitee.com/lailonghui/vehicle-supervision-framework/pkg/dicts"

// 终端-终端协议指令结果
type terminalInstructionResult int

var TerminalInstructionResult terminalInstructionResult

// 成功
func (c *terminalInstructionResult) Success() int {
	return 1
}

// 失败
func (c *terminalInstructionResult) Failure() int {
	return 2
}

func (c *terminalInstructionResult) ToText(value int) string {
	switch value {

	case 1:
		return "成功"

	case 2:
		return "失败"

	}
	return ""
}

func (c *terminalInstructionResult) ToDict(value int) *dicts.IntDict {
	return &dicts.IntDict{
		Text:  c.ToText(value),
		Value: value,
	}
}

func (c *terminalInstructionResult) ToValue(text string) int {
	switch text {

	case "成功":
		return 1

	case "失败":
		return 2

	}
	return 0
}
